package com.anis.project.medcare.search.tree.providers;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import com.anis.jpa.medical.model.Common;
import com.anis.jpa.medical.model.MedicalReport;
import com.anis.jpa.medical.model.Patient;
import com.anis.project.medcare.Activator;

public class SearchReportLabelProvider extends LabelProvider implements
		ITableLabelProvider {

	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		Image image = null;
		if (element instanceof Patient) {
			switch (columnIndex) {
			case 0:
				image = Activator.getDefault().getImage("Patient");
				break;
			case 1:
				image = null;
				break;
			}
		} else if (element instanceof MedicalReport) {

			switch (columnIndex) {
			case 0:
				image = null;
				break;
			case 1:
				if(((MedicalReport)element).getReportType().equals(Common.MEDREPTYPE))
				  image = Activator.getDefault().getImage("Document");
				else
				image = Activator.getDefault().getImage("dcmicon");
				break;
			}
		}
		return image;
	}

	@Override
	public String getColumnText(Object element, int columnIndex) {
		String nametoReturn = "No Report";
		if (element instanceof Patient) {
			switch (columnIndex) {
			case 0:
				nametoReturn = ((Patient) element).getPatientname();
				break;
			case 1:
				nametoReturn = "";
				break;
			case 2:
				nametoReturn = "";
				break;
			}
		} else if (element instanceof MedicalReport) {
			switch (columnIndex) {
			case 0:
				nametoReturn = "";
				break;
			case 1:
				nametoReturn = ((MedicalReport) element).getReportName();
				break;
			case 2:
				nametoReturn = ((MedicalReport) element).getReportDescription();
				break;
			}
		}
		return nametoReturn;
	}

}
